﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="lp_All_Collection.aspx.cs"
    Inherits="ZLDC.Estate.Quantify.workurl.lp_All_Collection" %>

<%@ Register Src="../UserControl/Dept_Tree.ascx" TagName="Dept_Tree" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script>

    <link href="../css/main1.css" rel="stylesheet" type="text/css" />

    <script src="../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

    <script src="popup/popup2/popup.js" type="text/javascript"></script>

    <style type="text/css">
        .table
        {
            text-align: center;
            margin-top: 5px;
        }
        .text
        {
            line-height: 22px;
            padding: 0 6px;
            color: #666;
        }
        .box h1
        {
            padding-left: 10px;
            height: 22px;
            line-height: 22px;
            background: #f1f1f1;
            font-weight: bold;
        }
        .box
        {
            text-align: center;
            position: relative;
            border: 1px solid #e7e7e7;</style>

    <script type="text/javascript">
        function yztxt() {
            if (document.getElementById('txtMessage').value == '') {
                document.getElementById('txtMessage').focus();
                return false;
            }
            return true;
        }
        // 收缩展开效果
        $(document).ready(function() {
            // $(".box h1").toggle(function(){
            //   $(this).next(".text").animate({height: 'toggle', opacity: 'toggle'}, "slow");
            //  },function(){
            //$(this).next(".text").animate({height: 'toggle', opacity: 'toggle'}, "slow");
            //});
            $("div.text").hide(); //默认隐藏div，或者在样式表中添加.text{display:none}，推荐使用后者
            $(".box span").click(function() {
                $(this).next(".text").slideToggle("slow");
            })
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="box">
        <span style="cursor: pointer; color: Blue; font-weight: bold">(点击)-->发表意见</span>
        <div class="text">
            <div style="background-color: Black">
                <table cellpadding="0" cellspacing="0" border="0" align="center" style="margin-top: 20px;">
                    <tr>
                        <td>
                            <a id="a1" onclick="qxmainid()"></a>
                            <asp:TextBox ID="txtMessage" runat="server" Height="200px" TextMode="MultiLine" MaxLength="6000"
                                Width="406px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <asp:Button ID="Button2" runat="server" Text="保 存" CssClass="button1" OnClick="Button1_Click"
                                OnClientClick="return yztxt()" />
                            <%-- <input id="Button3" type="button" value="取消回复" class="button1" onclick="qxmainid()" />--%>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <table cellpadding="0" cellspacing="0" border="0" align="center" style="margin-top: 0px;">
        <tr>
            <td>
                <div style="width: 100%; margin-top: 25px; margin-left: 30px;">
                    部门:<uc1:Dept_Tree ID="Dept_Tree1" runat="server" />
                    &nbsp;日期时间:<input id="txtstatrdate" class="txtbox" type="text" onclick="WdatePicker()" />~<input
                        id="txtenddate" type="text" class="txtbox" onclick="WdatePicker()" /><input id="Button1"
                            type="button" class="button1" value="查询" onclick="typepk();divlp(1)" />
                    <div id="divpagelist">
                    </div>
                    <div id="divpage">
                    </div>
                </div>
            </td>
        </tr>
    </table>

    <script type="text/javascript">
        var currentPage = 1; // 当前页
        var pageSize = 30; // 每页显示多少条
        var pageall = 0; // 总页数
        var total = 0; // 总记录数
        // var page = 1;//指定页
        var type = '<%=type %>';
        function typepk() {
            type = '';
        }
        window.onload = function divlp(currentPage) {
            var deptId = "";
            deptId = $("#utxdeptid").val(); // 部门ID
            if (document.getElementById('umainclass').value == "") {
                deptId = "";
            }


            var txtstatrdate = document.getElementById('txtstatrdate').value;
            var txtenddate = document.getElementById('txtenddate').value;
            document.getElementById('divpagelist').innerHTML = "<img src=\"../../images/loading.gif\"  />";
            $.ajax({
                type: "POST",
                url: "AjaxServer.aspx",
                dataType: 'json',
                data: "alt=CollectionList&type=" + type + "&deptid=" + deptId + "&txtenddate=" + txtenddate + "&&txtstatrdate=" + txtstatrdate + "&pagesize=" + pageSize + "&page=" + currentPage + "",
                processData: false,
                timeout: '10000',
                success: function(msg) {

                    divPageList(msg);
                },
                error: function() {
                    document.getElementById('divpagelist').innerHTML = "系统繁忙";
                }

            });
        }


        function divPageList(msg) {

            pageall = msg.page.pages;
            currentPage = msg.page.currentpage;
            var operation = document.getElementById('hidOperation').value;//是否有删除权限

            total = msg.page.intResult;
            var arr = [];
            arr.push("<table id='tb1' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce' class=\"table\" width='1100px' valign='top'>");
            arr.push("<tr bgcolor=\"#353c44\" >");
            arr.push("<td width=\"80px\"  style='text-align: center;background-color: #d3eaef'  >");
            arr.push("<div >楼</div>");
            arr.push("</td>");
            arr.push("<td width=\"80px\"  style='text-align: center;background-color: #d3eaef'  >");
            arr.push("<div >姓名</div>");
            arr.push("</td>");


            arr.push("<td width=\"200px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >内容</div>");
            arr.push("</td>");
            arr.push("<td width=\"80px\"  style='text-align: center;background-color: #d3eaef'  >");
            arr.push("<div >回复（次数）</div>");
            arr.push("</td>");
            arr.push("<td width=\"140px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >日期</div>");
            arr.push("</td>"); arr.push("<td width=\"125px\"  style='text-align: center;background-color: #d3eaef'>");
            arr.push("<div >部门</div>");
            arr.push("</td>");
            arr.push("</tr>");
            for (var i = 0; i < msg.record.length; i++) {
                if (i % 2 == 0)
                    arr.push("<tr bgcolor='#FFFFFF'>");
                else
                    arr.push("<tr bgcolor='#EEEDED'>");
                arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                arr.push(msg.record[i].id + (msg.record[i].collectiontop == "1" ? "&nbsp;&nbsp;<a style='color:red'>置顶</a>" : ""));
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                arr.push(msg.record[i].username);
                arr.push("</td>");
                arr.push("<td height='20'    style='text-align: center;'>");
                arr.push(msg.record[i].message + "<a style='color:blue' onclick=\"hf(" + msg.record[i].id + "," + msg.record[i].number + ",this)\">回复</a>" + "<div></div>");
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                arr.push("<a style='color:red;font-weight:bold' onclick=\"jz(this,'tb1'," + msg.record[i].id + ")\">" + (msg.record[i].number == "0" ? msg.record[i].number : msg.record[i].number + "打开") + "</a>");
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                arr.push(msg.record[i].createtime);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                arr.push(msg.record[i].depttype);
                arr.push("</td>");
                if (operation != 'False') {
                    arr.push("<td height='20' class='STYLE6'  style='text-align: center;'>");
                    arr.push("<a onclick=\"Collection_delete(" + msg.record[i].id + ",this)\">删除</a>");
                    arr.push("</td>");
                }
                arr.push("</tr>");
            }
            arr.push("</table>");
            arr.push("<div id=\"div7Page\" ></div>");
            document.getElementById('divpagelist').innerHTML = arr.join('');


            $("#div7Page").html(""); // 清空
            if (pageall > 1) {
                var pageHtml = LexunJS.showPage2(currentPage, pageall, "divlp"); // 分页
                $("#div7Page").html(pageHtml);
            }

        }

        function Collection_delete(id, obj) {

            var tablename = 'lp_Collection';
            var tbl = document.getElementById('tb1');
            var rowIndex = obj.parentNode.parentNode.rowIndex;
            if (confirm('确定删除？')) {
                $.ajax({
                    type: "POST",
                    url: "AjaxServer.aspx",
                    dataType: 'json',
                    data: "alt=Collection_delete&id=" + id + "&tablename=" + tablename + "",
                    processData: false,
                    timeout: '10000',
                    success: function(msg) {
                        // window.location.href = location.href;


                        tbl.deleteRow(rowIndex);
                    },
                    error: function() {
                        alert('错误!');
                    }

                });
            }
        }

        function jz(obj, tbname, mainid) {

            var tbl = document.getElementById(tbname);
            var rowIndex = obj.parentNode.parentNode.rowIndex;
            tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML = "<img src=\"../../images/loading.gif\"  />";
            $.ajax({
                type: "POST",
                url: "AjaxServer.aspx",
                dataType: 'json',
                data: "alt=Collectionhf&mainid=" + mainid + "",
                processData: false,
                timeout: '10000',
                success: function(msg) {
                    tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML = "";
                    for (var i = 0; i < msg.msg.length; i++) {
                        tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML += "<br><span style='color:green;font-weight:bold'>" + msg.msg[i].username + " 回复说:</span><span style='color:red;font-weight:bold'>" + msg.msg[i].message + "</span><span style='color:blue;font-weight:bold'>(" + msg.msg[i].createtime + ")</span>";
                    }
                },
                error: function() {
                    tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML = "系统繁忙";
                }

            });
        }
        function parentjz(rowindex, mainid) {

            var tbl = document.getElementById('tb1');
            var rowIndex = rowindex;
            tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML = "<img src=\"../../images/loading.gif\"  />";
            $.ajax({
                type: "POST",
                url: "AjaxServer.aspx",
                dataType: 'json',
                data: "alt=Collectionhf&type=1&mainid=" + mainid + "",
                processData: false,
                timeout: '10000',
                success: function(msg) {
                    tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML = "";
                    for (var i = 0; i < msg.msg.length; i++) {
                        tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML += "<br><span style='color:green;font-weight:bold'>" + msg.msg[i].username + " 回复说:</span><span style='color:red;font-weight:bold'>" + msg.msg[i].message + "</span><span style='color:red;font-weight:bold'>(" + msg.msg[i].createtime + ")</span>";
                    }
                },
                error: function() {
                    tbl.rows[rowIndex].cells[2].childNodes[2].innerHTML = "系统繁忙";
                }

            });
        }
        function hf(mainid, number, obj) {
            var txt = '回复:' + mainid + '楼';
            document.getElementById('hidmainid').value = mainid;
            document.getElementById('hidnumber').value = number;
            //document.getElementById('txtMessage').focus();
            var tbl = document.getElementById('tb1');
            var rowIndex = obj.parentNode.parentNode.rowIndex;
            ShowIframe("workurl/lp_Collection.aspx?rowIndex=" + rowIndex + "&mainid=" + mainid, 400, 250, txt);
        }
        function qxmainid() {
            document.getElementById('hidmainid').value = '';
            document.getElementById('hidnumber').value = '0';
            document.getElementById('a1').innerHTML = '';
        }
    </script>

    <div style="font-weight: bold">
    </div>
    <input id="hidmainid" runat="server" type="hidden" />
    <input id="hidnumber" runat="server" type="hidden" />
    <input id="hidtype" runat="server" type="hidden" />
    <input id="hidOperation" runat="server" type="hidden" />

    <script src="../../js/LexunJS.js" type="text/javascript"></script>

    </form>
</body>
</html>
